<template>
    <div>
        <tit title="搜索"></tit>
        <van-search v-model="value" shape="round" background="#4fc08d" placeholder="请输入搜索关键词" />
        <div v-for="item in ss">
            <router-link :to="{ name: 'xq', params: { goods_id: item.goods_id } }">
                <van-card :price="item.goods_price" :title="item.goods_name" :thumb="item.goods_small_logo" />
            </router-link>

        </div>

    </div>
    <van-empty  @search="kong" image="https://fastly.jsdelivr.net/npm/@vant/assets/custom-empty-image.png" image-size="80"
        description="描述文字" />
</template>

<script setup>
import { searchApi } from '@/api/api';
import { ref, watch } from 'vue';
let value = ref('')
let ss = ref([]);
watch((value), val => {
    searchApi(val).then(res => {
        console.log('搜所', res);
        ss.value = res.data.message.goods
        if(res.data.message.total){
            kong.value=true
        }
        else{
            kong.value=false
        }
    })
})

let kong=ref(false)

</script>

<style lang="scss" scoped></style>